﻿picShare.service('logoutSvc', function (httpRequestSvc, localStorageSvc, pageLocatorSvc) {
    var logoutUser = function () {
        var sessionKey = localStorage.getItem("sessionKey");
        httpRequestSvc.putJson(httpRequestSvc.httpRootUserUrl + "logout", {}, sessionKey).done(
            function (data) {
//                console.log("logged out");
                localStorage.removeItem("sessionKey");
                localStorageSvc.deleteUserInfo();
                pageLocatorSvc.goTo("/");
            }, function (err) {
                alert("error");
            });
    };

    return {
        logoutUser: logoutUser
    };
});